<template>
    <el-drawer v-model="visible" :with-header="false" :size="1000" destroy-on-close @closed="$emit('closed')">
        <el-container v-loading="loading">
            <el-main style="padding:20px 20px 20px 20px" class="">
                <el-container class="is-vertical">
                    <sc-title title="教练详情"></sc-title>
                    <div>
                        <el-tabs v-model="activeName" @tab-click="tabClickFun">
                            <el-tab-pane label="基本信息" name="first">
                                <el-form ref="form" label-width="120px" class="formshows" label-position="right" size="small">
                                    <div class="info">
                                        <el-row>
                                            <el-col :span="24">
                                                <el-row>
													<el-col :span="12">
                                                        <el-form-item label="头像:">
															<img style="width: 60px; height: 60px" :src="info.portrait.url" v-if="info.portrait">
														</el-form-item>
                                                    </el-col>
												</el-row>
                                                <el-row>
                                                    <el-col :span="12">
                                                        <el-form-item label="姓名:">{{info.name}}</el-form-item>
                                                        <el-form-item label="生日:">{{info.birthday}}</el-form-item>
                                                        <el-form-item label="等级:">{{info.level && info.level.name}}</el-form-item>
                                                        <el-form-item label="头衔:">{{info.title && info.title.name || ''}}</el-form-item>
                                                        <el-form-item label="考核:">
															{{ info?.auditStatus?.name }}
														</el-form-item>
                                                        <el-form-item label="状态:">
															<el-tag size="mini" v-if="info.status && info.status.value == 0" type="danger">{{ info.status.name }}</el-tag>
                                                            <el-tag size="mini" v-if="info.status && info.status.value == 1" type="success">{{ info.status.name }}</el-tag>
														</el-form-item>
                                                        <el-form-item label="银行卡号:">{{info.bankCode}}</el-form-item>
                                                        <el-form-item label="推荐人:">{{info.recommender || '无'}}</el-form-item>
                                                        <el-form-item label="创建时间:">{{info.createdAt}}</el-form-item>
                                                    </el-col>
                                                    <el-col :span="12">
                                                        <el-form-item label="手机:">{{info.mobile || ''}}</el-form-item>
                                                        <el-form-item label="性别:">{{ info?.gender?.name }}</el-form-item>
                                                        <el-form-item label="头衔:">{{info.title && info.title.name || ''}}</el-form-item>
                                                        <el-form-item label="推荐码:">{{ info.recommendCode}}</el-form-item>
                                                        <el-form-item label="所属机构:">{{ info?.agent?.name || ''}}</el-form-item>
                                                        <el-form-item label="教学练习:">{{info?.teachExercise?.name}}</el-form-item>
                                                        <el-form-item label="开户人姓名:">{{info.bankUserName}}</el-form-item>
                                                        <el-form-item label="开户银行全称:">{{info.bankFullName}}</el-form-item>
                                                    </el-col>
                                                </el-row>
                                            </el-col>
                                        </el-row>
                                    </div>
                                    <div class="info">
                                        <div class="title">身份证照片</div>
                                        <div class="sc-upload-list" v-if="info.idCardImg && info.idCardImg.length > 0">
                                            <ul>
                                                <li v-for="(file, index) in info.idCardImg" :key="index">
                                                    <div class="sc-upload-item">
                                                        <el-image class="image" :src="file.url" fit="cover" :preview-src-list="previewIdCardImgs" hide-on-click-modal append-to-body :z-index="3500">
                                                            <template #placeholder>
                                                                <div class="image-slot">
                                                                    <i class="el-icon-more"></i>
                                                                </div>
                                                            </template>
                                                        </el-image>
                                                    </div>
                                                </li>
                                            </ul>
                                        </div>
                                        <el-empty v-else description="暂无身份证照片" :image-size="40" style="padding:0px;"></el-empty>
                                    </div>
                                </el-form>
                            </el-tab-pane>

                            <el-tab-pane label="体验记录" name="second" >
                                <learn-table :teacherId="infoId" :learnType="2" v-if="activeName == 'second'" ></learn-table>
                            </el-tab-pane>


                            <el-tab-pane label="上课记录" name="third" >
                                <user-learn-table :teacher="info"  v-if="activeName == 'third'" ></user-learn-table>
                            </el-tab-pane>


                        </el-tabs>
                    </div>
                </el-container>
            </el-main>
            <el-footer>
                <el-button @click="visible=false">关闭</el-button>
            </el-footer>
        </el-container>
    </el-drawer>

</template>

<script>
import learnTable from '../learn/components/table.vue'
import userLearnTable from '../learn/components/learnTable.vue'
import brokerageTable from './components/brokerageTable.vue'
export default {
    components: {
        learnTable,
        brokerageTable,
        userLearnTable
    },
    data() {
        return {
            visible: false,
            loading: false,
            dialog: {
                audit: false
            },
            info: {},
            infoId: null,
            activeName: 'first',
            previewIdCardImgs: [],
        }
    },
    mounted() {
     
    },
    methods: {
        open(id, activeName) {
            this.activeName = activeName || 'first'
            this.visible = true
            this.infoId = id
            this.getData(id)
        },
        async getData(id) {
            this.loading = true
            await this.$API.teacher.action.get({id: id}).then((res) => {
                this.info = res.data
                if (res.data.idCardImg) {
                    res.data.idCardImg.forEach(item => {
                        item.path && this.previewIdCardImgs.push(item.url)
                    })
                }
                this.loading = false
            }, () => {
                this.loading = false
            })
        },
        handleSuccess() {
            this.getData(this.infoId)
        }
    }
}
</script>

<style scoped>
.tcontainer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
}
.title {
    font-size: 14px;
    padding-left: 6px;
    font-weight: 500;
    padding-bottom: 20px;
}
.info {
    padding-bottom: 10px;
    margin-bottom: 10px;
}
.info:last-child {
    border: none;
    padding-bottom: 0;
    margin-bottom: 0;
}
[data-theme="dark"] .info {
    border-color: #434343;
}
:deep(.el-form-item__content) {
    font-size: 12px !important;
}
:deep(.el-image-viewer__close) {
    background-color: unset;
}
.el-form-item__label {
    text-align: justify;
}
</style>
